//获取url参数(非hash模式)
const getURLhandler = (url = '/constructionProjectManage/project_mt/components/projectInfo/type=1&id=1') => {
  let list = url.split('/')
  let strs = list[list.length - 1].split('&');
  // console.log(strs);
  let obj = {}
  strs.map(item => {
    let arr = item.split('=')
    obj[arr[0]] = arr[1]
  })
  return obj
}

//生成全局唯一标识符 nanoid
const nanoid = (size = 21) => {
  let id = ''
  let bytes = crypto.getRandomValues(new Uint8Array(size))
  while (size--) {
    let byte = bytes[size] & 63
    if (byte < 36) {
      id += byte.toString(36)
    } else if (byte < 62) {
      id += (byte - 26).toString(36).toUpperCase()
    } else if (byte < 63) {
      id += '_'
    } else {
      id += '-'
    }
  }
  return id
}
export {
  getURLhandler,
  nanoid
}
